import {createRouter,createWebHistory} from 'vue-router'


//导入组件
import {ElNotification} from "element-plus";
import {getStorage} from "@/utils/localStorage.js";

//路由关系
const routes = [
    {
        path: '/',
        redirect: '/systemImp',
    },
    {
        path:'/main',
        redirect: 'main/dataPreprocessing',
        meta: {
            name:"程序员页面",
        },
        component: () => import("@/view/Main.vue"),
        children: [
            {
                path:'/main/dataPreprocessing',
                component: () => import("@/view/DataPreprocessing.vue")
            },
            {
                path:'/main/algorithmDesign',
                component: () => import("@/view/AlgorithmDesign.vue")
            }
        ]
    },
    {
        path:'/systemImp',
        meta: {
            name:"广告主页面"
        },
        component: () => import("@/view/SystemImp.vue")
    }
]

//创建路由器
const router = createRouter({
    history:createWebHistory(),
    routes:routes
})

// // 全局前置守卫
// router.beforeEach((to, from, next) => {
//     const token = getStorage('Token')
//     const requiresLogin = to.matched.some(record => record.meta.requiresLogin); // 检查是否需要登录
//     if (requiresLogin && token === null) {
//
//         // 如果需要登录但用户未登录，则重定向到登录页面
//         ElNotification({
//             title: '用户未登录',
//             message: "请先登录系统",
//             type: 'warning',
//         })
//         next('/login');
//     } else {
//         next();
//     }
// });

export default router